package com.gy.springboot.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.gy.springboot.entity.Department;

// 定义这是一个操作数库的mapper
// 基于注解的用 mapper  基于 xml sql的 用dao
// @Mapper
public interface DepartmentMapper {

    @Select("select * from department where id = #{id}")
    public Department getDepById(Integer id);

    @Delete("delete from department where id = #{id}")
    public int deleteDepById(Integer id);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into department(department_name) values (#{departmentName})")
    public int insertDept(Department department);

    @Update("update department set department_name = #{departmentName} where id = #{id}")
    public int updateDepById(Department department);

    @Select("select * from department where department_name = #{departmentName}")
    public Department getDepByDeptName(String departmentName);

}
